/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
*   Nick Kreeger
* Portions created by the Initial Developer are Copyright (C) 2006-2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*   Nick Kreeger <nick.kreeger@park.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

#import <Cocoa/Cocoa.h>
#import "CHBrowserView.h"

@class AttachmentView;
@class ComposerContentView;
@class SendingProgressWindow;
class nsIMsgComposeParams;
class CHMsgComposeWindow;

extern NSString* const kCompositionWindowWillCloseNotification;

/**
 * Any object interested in the state of a composer instance
 * should implement this protocol, and register with the 
 * CHMsgComposeStateListener class.
 */
@protocol ComposerStateListenerDelegate

-(void)onComposeFieldsReady;
-(void)onSaveInFolderDone:(NSString*)aFolderName;
-(void)onComposeBodyReady:(NSString*)inBodyText;
-(void)showComposeWindow;
-(void)onStatus:(NSString*)aMessage;
-(void)onProgress:(int)aProgress maxProgress:(int)aMaxProgress;
-(void)showProgressDialog;
-(void)closeProgressDialog;
-(void)onComposeProcessDone;

@end

/**
 * This is the controller class for a composition window. All actions that 
 * need to interact with the lower layers of gecko are passed down to our
 * delegate |mCompWindowDelegate|.
 */
@interface CompositionWindowController : NSWindowController<ComposerStateListenerDelegate>
{
@private
  IBOutlet ComposerContentView*   mComposerContentView;
  IBOutlet AttachmentView*        mAttachmentView;
  IBOutlet SendingProgressWindow* mSendProgWindow;
  IBOutlet NSTextField*           mToField;
  IBOutlet NSTextField*           mCcField;
  IBOutlet NSTextField*           mSubjectField;
  
  CHMsgComposeWindow* mMsgComposeWindow;
  CHBrowserView*      mCHBrowserView;
  
  BOOL mCompFieldsReady;
  BOOL mCompBodyReady;
  BOOL mIsComposeProcessDone;
}

-(void)initializeComposer:(nsIMsgComposeParams*)aMsgComposeParams;

-(CHBrowserView*)browserView;

/**
 * Add a comma-seperated value of email addresses to the 'to:' field.
 * @param A comma-seperated string of email addresses.
 */
-(void)addToContacts:(NSString*)aContactString;

-(IBAction)send:(id)sender;
-(IBAction)cancelSend:(id)sender;
-(IBAction)attach:(id)sender;
-(IBAction)openAddressBook:(id)sender;
-(IBAction)saveAsDraft:(id)sender;

-(BOOL)isComposeProcessDone;

@end

/**
 * This class serves as a wrapper for showing a composer's text field
 * and attachment view.
 */
@interface ComposerContentView : NSView
{
@private
  IBOutlet AttachmentView* mAttachmentView;
  IBOutlet NSTextView*     mBodyField;
  IBOutlet NSScrollView*   mScrollView;
  
  BOOL mIsAttachmentViewVisible;
}

-(void)setBodyText:(NSString*)inBodyText;
-(NSString*)bodyText;

-(void)updateAttachmentList:(NSArray*)inAttachmentArr;
-(void)showAttachments;
-(void)hideAttachments;

@end

/**
 * Provide a class to show at least some primative feedback
 * on sending progress.
 */
@interface SendingProgressWindow : NSWindow
{
  IBOutlet NSProgressIndicator* mProgIndicator;
  IBOutlet NSTextField*         mStatusField;
  IBOutlet NSWindow*            mParentWindow;
}

-(void)showProgressDialog;
-(void)stopPorgressDialog;
-(void)setStatusString:(NSString*)aStatusString;
-(void)updateProgress:(int)aProgress maxProgress:(int)aMaxProgress;

@end
